﻿package mortal.game.view.chat.selectPanel
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;

    public class SelectTypePanel extends CallSprite
    {
        private var _dataArray:Array;
        private var _aryBtn:Array;

        public function SelectTypePanel(param1:Array)
        {
            this._aryBtn = [];
            this._dataArray = param1;
            this.createChildren();
            return;
        }// end function

        private function createChildren() : void
        {
            var _loc_1:* = ResourceConst.getScaleBitmap(ImagesConst.ToolTipBg);
            _loc_1.width = 55;
            _loc_1.height = this._dataArray.length * 23 + 10;
            this.addChild(_loc_1);
            var _loc_2:int = 0;
            while (_loc_2 < this._dataArray.length)
            {
                
                this.createButton(_loc_2, this._dataArray[_loc_2]);
                _loc_2++;
            }
            return;
        }// end function

        private function createButton(param1:int, param2:Object) : void
        {
            var _loc_3:* = new GButton();
            _loc_3.x = 6;
            _loc_3.y = param1 * 23 + 5;
            _loc_3.width = 43;
            _loc_3.height = 22;
            _loc_3.styleName = "ChatBtn";
            _loc_3.name = param2["name"];
            _loc_3.label = param2["label"];
            _loc_3.textField.filters = [FilterConst.glowFilter];
            _loc_3.addEventListener(MouseEvent.CLICK, this.btnClickHandler);
            this.addChild(_loc_3);
            this._aryBtn.push(_loc_3);
            return;
        }// end function

        private function btnClickHandler(event:MouseEvent) : void
        {
            callAll((event.target as GButton).name);
            return;
        }// end function

        public function updateData(param1:Array) : void
        {
            this._dataArray = param1;
            var _loc_2:int = 0;
            while (_loc_2 < this._dataArray.length)
            {
                
                (this._aryBtn[_loc_2] as GButton).label = this._dataArray[_loc_2]["label"];
                _loc_2++;
            }
            return;
        }// end function

    }
}
